﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace ArrayListText
{
    class ListText
    {
        static void Main(string[] args)
        {
            //集合
            ArrayList list = new ArrayList() { "111", "222", "333",1 };
           
            foreach (var v in list)
            {
                Console.WriteLine(v);
            }

            //用IndexOf寻找"111"
            int index = list.IndexOf("111");
            if (index != -1)
            {
                Console.WriteLine("存在");
            }
            else
            {
                Console.WriteLine("不存在");
            }

            //用Remove移除"111"
            list.Remove("111");
            foreach(var v in list)
            {
                Console.WriteLine(v);
            }

            //用AddRange添加集合
            ArrayList arraylist = new ArrayList() { "1", "2", "3",};
            string[] input = { "4", "5" };
            arraylist.AddRange(input);
            foreach (var v in arraylist)
            {
                Console.WriteLine(v);
            }

            //用Contains判断是否有"1"
            bool i = arraylist.Contains("1");
            if (i)
            {
                Console.WriteLine(true);
            }
            else
            {
                Console.WriteLine(false);
            }

            //使用Sort将集合排序
            ArrayList mylist = new ArrayList() { "嘤嘤嘤","嘤嘤",110};
            MyCompare myCompare = new MyCompare();
            mylist.Sort(myCompare);
            foreach (var v in mylist)
            {
                Console.WriteLine(v);
            }

            Program pr = new Program();
            pr.Age = 10;
            Program pr1 = new Program();
            pr1.Age = 11;
            var vv = pr.CompareTo(pr1);
            Console.WriteLine(vv);
        }
    }
}
